package com.atomdayl.domain.therecipe.network;

/**
 * 生成Request工具类
 * Created by David on 2016/6/4.
 */
public class RequestBuildManager {

    private static RequestBuildManager mInstance;
    private RequestBuildManager() {}

    public static RequestBuildManager getInstance() {
        if(mInstance == null) {
            synchronized (RequestBuildManager.class){
                if(mInstance == null) {
                    mInstance = new RequestBuildManager();
                }
            }
        }
        return mInstance;
    }

    /**
     * 生成LoginRequest
     * @param username
     * @param password
     * @return
     */
    public String buildLoginRequest(String username, String password) {
//        http://localhost/recipe/shiPu/loginJiek.php?username=102mengtong@126.com&password=102
        StringBuffer sb = new StringBuffer();
        //前缀
        sb.append(NetworkManager.SERVER_IP + NetworkManager.SERVER_PORT);
        sb.append(NetworkManager.URL);
        sb.append("loginJiek.php?");
        //账号
        sb.append("username=");
        sb.append(username);
        //密码
        sb.append("&");
        sb.append("password=");
        sb.append(password);
        return sb.toString();
    }

    /**
     *  生成注册Request
     * @param eUser
     * @param ePass
     * @return
     */
    public String buildRegisterRequest(String eUser, String ePass) {
        //http://localhost/recipe/shiPu/registerJiek.php?e-user=102mengtong@126.com&e-pass=102
        StringBuffer sb = new StringBuffer();
        //前缀
        sb.append(NetworkManager.SERVER_IP + NetworkManager.SERVER_PORT);
        sb.append(NetworkManager.URL);
        sb.append("registerJiek.php?");
        //账号
        sb.append("e-user=");
        sb.append(eUser);
        //密码
        sb.append("&");
        sb.append("e-pass=");
        sb.append(ePass);
        return sb.toString();
    }

    /**
     * 生成修改密码Request
     * @param username
     * @param password
     * @return
     */
    public String buildChangePasswordRequest(String username, String password) {
        //http://localhost/recipe/shiPu/renameJiek.php?username=102mengtong@126.com&newpass=10
        StringBuffer sb = new StringBuffer();
        //前缀
        sb.append(NetworkManager.SERVER_IP + NetworkManager.SERVER_PORT);
        sb.append(NetworkManager.URL);
        sb.append("renameJiek.php?");
        //账号
        sb.append("username=");
        sb.append(username);
        //密码
        sb.append("&");
        sb.append("newpass=");
        sb.append(password);
        return sb.toString();
    }
}

